#!/bin/bash
echo "#####数组定义与引用"
arr=("kuso" 123 "money" "ash")
echo "${#arr}"
unset arr[2]
echo "${arr[@]}"
echo "${#arr[@]}"
echo "${arr[1]}"
echo "${#arr}"

arr[1]=234

echo "${arr[1]}"

arr=([1]=234 [3]="kuso" [5]="no")
echo "${arr[@]}"
echo "${arr[*]}"

echo "#####数组合并"

arr1=("no" "ash")
arr2=("123" 47 "root")
new_arr=("${arr1[@]}" "${arr2[@]}")

echo "${new_arr[@]}"

echo "#####关联数组(Map)"
declare -A map=(["name"]="kusosun" ["sex"]="male" ["lang"]="zh_CN")

echo "${#map[@]}"
echo "${map[*]}"
echo "${!map[@]}"

declare -A map
map["age"]=23
map["money"]=0

echo "${#map[@]}"
echo "${map[*]}"
echo "${!map[@]}"

echo $(map["age"])


